import { Application } from 'egg';

export default (app: Application) => {
  const { DataTypes: { STRING, DATE, INTEGER,TEXT } } = app.Sequelize;

  const Model = app.model.define('recyclingBag', {
    id: { // 主键
      type: INTEGER,
      primaryKey: true,
      autoIncrement: true
    },
    name: { // 名称
      type: STRING(100)
    },
    city:{
      type:STRING(100)
    },
    province:{
      type:STRING(100)
    },
    phone: { // 联系方式
      type: STRING(20)
    },
    code: { // 编码
      type: STRING(50),
      unique: true // 假设编码需要唯一
    },
    image: { // 图片URL
      type: STRING(255)
    },
    note:{
        type:TEXT
    },
    status:{
      type:INTEGER
    },
    createdAt: {
      type: DATE,
      allowNull: true,
      field: 'created_at',
      comment: '创建时间',
    },
    updatedAt: {
      type: DATE,
      allowNull: true,
      field: 'updated_at',
      comment: '修改时间',
    },
  },
  {
    comment: '回收袋信息', // 模型注释
    tableName: 'recycling_bag', // 表名
  });

  return class RecyclingBagModel extends Model {
    id?: number;
    name?: string;
    status:number
    phone?: string;
    city?:string
    province?:string
    code?: string;
    image?: string;
    createdAt?: Date;
    updatedAt?: Date;
  };
};